-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor: Snackbar Manager #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit refactors the way `SnackBarController` is accessed and used within composables. - Introduces `rememberSnackBarController()` composable function in the `designSystem` module to retrieve the `LocalSnackbarController` instance. - Updates `ViewItemsScreen`, `BookmarkSheet`, and `ListScreen` in the `presentation` module to use `rememberSnackBarController()` instead of directly accessing `LocalSnackbarController.current`. - Removes the explicit `icon` parameter from `snackBarController.showMessage` calls as the icons are now likely handled internally by the `SnackBarController` based on the `SnackBarType`. - Changes `LocalSnackbarController` from `staticCompositionLocalOf` to `compositionLocalOf` for potentially better performance characteristics in some scenarios.
This commit introduces several enhancements to the SnackBar functionality within the design system: - Refactors `SnackBarController` and introduces `SnackBarData` for better state management and customization of SnackBar messages, types, and durations. - Implements `SnackBarControllerImpl` to handle the display logic and queuing of SnackBar messages using coroutines. - Adds `SnackBarState` to manage the visibility and data of the SnackBar. - Introduces `SnackbarDuration` enum to define standard display times for SnackBars (Short, Medium, Extensive, Indefinite). - Defines default icons for `Success` and `Error` `SnackBarType`s. - Updates `ScaffoldWithSnackBar` to use the new `SnackBarControllerImpl` and `SnackBarData`, and collects state using `collectAsStateWithLifecycle`. - Introduces `SnackBarAnimationConfig` to allow customization of SnackBar enter and exit animations and duration. - Renames `CustomSnackBarUI` to `DefaultSnackBar` for clarity. - Simplifies icon handling in `DefaultSnackBar` by using `data.snackBarType.getDefaultIcon().painter`.
This commit updates the SnackBar implementation across the app. - Replaced `showMessage` with `showSnackBar` and wrapped parameters in `SnackBarData` class for better organization in `ViewItemsScreen.kt`, `BookmarkSheet.kt`, and `ListScreen.kt`. - Renamed `CustomSnackBarUI` to `DefaultSnackBar` in `NavHostGraph.kt`. - Simplified `rememberSnackBarController()` in `LocalSnackbarController.kt`.
This commit refactors the error handling in the Login screen. - Removes the `SnackBarAnimation` composable and replaces it with the `SnackBarController` from the design system to display error messages. - Updates `LoginViewModel` to set a generic `ErrorState.RequestFailed` without a specific message, as the message is now handled by the UI.
This commit refactors the snackbar visibility logic in `ScaffoldWithSnackBar.kt` and `SnackBarControllerImpl.kt`. In `ScaffoldWithSnackBar.kt`: - The `AnimatedVisibility` composable now wraps the `snackBar(data)` call directly. - The null check for `currentSnackbarData.data` is now performed inside the `AnimatedVisibility` content. In `SnackBarControllerImpl.kt`: - The `processNextMessage` function now uses a `queueMutex` to safely remove the next message from the `messageQueue`. This prevents potential race conditions when accessing the queue. - If the queue is empty, the coroutine launched to process the message will now return early.
This commit refactors the `MovieDetailsScreen` to use the `rememberSnackBarController` and `SnackBarData` from the design system for displaying success and failure messages for ratings. This replaces the previous `SnackBarAnimation` composable. Key changes: - Integrated `rememberSnackBarController` to manage SnackBar display. - Used `SnackBarData` with `SnackBarType.Success` and `SnackBarType.Error` for rating feedback. - Removed the custom `SnackBarAnimation` composable. - Utilized the `.string` extension function for cleaner string resource access.
This commit updates the rating success/failure snackbar in `EpisodeDetailScreen.kt` to use the `SnackBarController` and `SnackBarData` from the design system, replacing the custom `SnackBarAnimation`. This change standardizes the snackbar implementation and leverages the design system's snackbar types (Success/Error).
This commit replaces the custom `SnackBarAnimation` with the `rememberSnackBarController` and `SnackBarData` from the design system for displaying success and failure messages for ratings. - Updated `TvShowDetailScreen.kt` to use `rememberSnackBarController` to manage SnackBar display. - Replaced `SnackBarAnimation` calls with `snackBarController.showSnackBar()` using `SnackBarData`. - Set `SnackBarType.Error` for both success and failure messages, which seems like a potential bug that might need further attention.
This commit removes the `SnackBarAnimation.kt` file as it is no longer needed. The functionality provided by this composable can be achieved using the snackBarController
This commit updates the `AppNavBar` composable: - Simplifies screen width calculation by directly using `LocalConfiguration.current.screenWidthDp.dp`.
This commit renames the `SnackbarDuration.Short` enum value to `SnackbarDuration.Brief` in `SnackBarController.kt`. The corresponding millisecond value remains unchanged at 1500.
Contributor
|
[London Bot] Metrics Update Status 📊 PR metrics successfully updated for event: |
Contributor
|
[London Bot] Auto-update Status ✅ Branch successfully updated from |
This commit removes the `Context` dependency from `LoginViewModelTest` after eliminating its usage for fetching string resources. The string resources `R.string.login_failed` and `R.string.guest_login_failed` were previously fetched using the `Context` but are no longer used by the ViewModel.
Code Coverage Summary
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.